﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="addTvStation.aspx.cs" Inherits="Com.CMS263.Web.manage.TvStation.addTvStation" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
          <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <link href="../common/validator.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        #title {
            width: 531px;
        }
    </style>
    <script language="javascript" type="text/javascript">
        function checkNum(obj) {
            var tempstr;
            //先把非数字的都替换掉，除了数字和.   
            tempstr = obj.value.replace(/[^\d]/g, "");
            obj.value = tempstr;
        }

        function changeProvince() {
            var id = $("#txtProvince").val();
            $.post("/area_action.aspx?op=province", { id: id }, function(data) {
                $("#txtCity").html("");
                $("#txtArea").html("<option value='0'>区</option>");
                var province = data.split(';');

                $.each(province, function() {
                    if (this != "" && this.length > 0) {
                        var co = this.split(',');
                        $("#txtCity").append("<option value='" + co[0] + "'>" + co[1] + "</option>");
                    }
                })
                var cid = $("#txtCity").val();
                $.post("/area_action.aspx?op=city", { id: cid }, function(data) {
                    $("#txtArea").html("");
                    var city = data.split(';');

                    $.each(city, function() {
                        if (this != "" && this.length > 0) {
                            var co = this.split(',');
                            $("#txtArea").append("<option value='" + co[0] + "'>" + co[1] + "</option>");
                        }
                    })

                })
            })
        }
        $(function() {
            var id = $("#txtProvince").val();
            $.post("/area_action.aspx?op=province", { id: id }, function(data) {
                $("#txtCity").html("");
                $("#txtArea").html("<option value='0'>区</option>");
                var province = data.split(';');

                $.each(province, function() {
                    if (this != "" && this.length > 0) {
                        var co = this.split(',');
                        $("#txtCity").append("<option value='" + co[0] + "'>" + co[1] + "</option>");
                    }
                })
                var cid = $("#txtCity").val();
                $.post("/area_action.aspx?op=city", { id: cid }, function(data) {
                    $("#txtArea").html("");
                    var city = data.split(';');

                    $.each(city, function() {
                        if (this != "" && this.length > 0) {
                            var co = this.split(',');
                            $("#txtArea").append("<option value='" + co[0] + "'>" + co[1] + "</option>");
                        }
                    })

                })
            })

        })
        function changeCity() {
            var id = $("#txtCity").val();
            $.post("/area_action.aspx?op=city", { id: id }, function(data) {
                $("#txtArea").html("");
                var city = data.split(';');

                $.each(city, function() {
                    if (this != "" && this.length > 0) {
                        var co = this.split(',');
                        $("#txtArea").append("<option value='" + co[0] + "'>" + co[1] + "</option>");
                    }
                })

            })
        }
        function save() {
            if ($("#Name").val().length < 1) {
                alert("名称必填！");
                $("#Name").focus();
                return false;
            } else if ($("#LogoPic").val().length < 1) {
                alert("logo图必填！");
                $("#LogoPic").focus();
                return false;
            } else if ($("#txtProvince").val() =="0") {
                alert("省份必选！");
                $("#txtProvince").focus();
                return false;
            } else if ($("#txtCity").val() == "0") {
                alert("城市必选！");
                $("#txtCity").focus();
                return false;
            } else if ($("#txtArea").val() == "0") {
                alert("区必选！");
                $("#txtArea").focus();
                return false;
            } else if ($("#Address").val().length < 1) {
                alert("地址必填！");
                $("#Address").focus();
                return false;
            } else if ($("#BigPic").val().length < 1) {
                alert("大图必填！");
                $("#BigPic").focus();
                return false;
            } else if ($("#telePhone").val().length < 1) {
                alert("电话必填！");
                $("#telePhone").focus();
                return false;
            } else {
            return true;
            }
        }
    </script>
</head>
<body>
   <form id="form1" runat="server" enctype="multipart/form-data">
    <div>
        <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" class="table_1">
            <tr>
                <td height="23" colspan="2" class="table_2">
                    添加/修改 <asp:label runat="server" id="lbTypeName">电视台</asp:label>
                </td>
            </tr>
            <tr>
                <td >
                    名称:
                </td>
                <td >
                 <input type="text" name="Name" id="Name" size="140" />
                &nbsp;</td>
            </tr>  
            <tr>
                <td class="tdleft">
                    logo图(154*76)</td>
                <td class="tdside">                
                    <input type='file' name="LogoPic" id="LogoPic" />                    
                </td>
            </tr>
          <tr>
                <td class="tdleft">
                    地址</td>
                <td class="tdside">
                <select id="txtProvince" name="txtProvince" onchange="changeProvince()">
                <% foreach (Com.CMS263.PO.Province prov in provlist)
                   {%>
                <option value="<%=prov.Code %>">
                    <%=prov.Name %></option>
                <%} %>
            </select> <select id="txtCity" name="txtCity" onchange="changeCity()">
                <option value="0">市</option>
            </select><select name="txtArea" id="txtArea">
                <option value="0">区</option>
            </select>
                     <input type="text" name="Address" id="Address" />
                    
                </td>
            </tr>
            <tr>
                <td class="tdleft">
                    大图(203*245)</td>
                <td class="tdside">
                <input type='file' name="BigPic" id="BigPic" />                       
                    
                </td>
            </tr>
             <tr>
                <td class="tdleft">
                    电话</td>
                <td class="tdside">
                <input type='text' name="telePhone" id="telePhone" onkeyup="checkNum(this);" onblur="checkNum(this);" size="25"/>                       
                    
                </td>
            </tr>
            <tr>
                    <td class="tdleft">
                       </td>
                    <td class="tdside">
                        <asp:Button ID="btnSave" runat="server" Text="保存" onclick="btnSave_Click"  OnClientClick="return save();" />                         
                    </td>
                </tr>
        </table>
    </div>
    </form>
</body>
</html>
